package com.ruoyi.framework.schedul;

import com.ruoyi.project.system.service.ISysGoodsOrderService;
import com.ruoyi.project.system.service.ISysServiceOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@EnableScheduling   // 1.开启定时任务
public class ServiceOrderSch {


    @Autowired
    private ISysServiceOrderService sysServiceOrderService;

    @Autowired
    private ISysGoodsOrderService sysGoodsOrderService;

    /**
     * 服务订单从开始服务到服务结束时间结束超过七天自动确认服务
     * @throws InterruptedException
     */
//    @Scheduled(cron = "0 */1 * * * ?")//每隔一分钟执行一次
    @Scheduled(cron = "0 0 1 * * ?")//每天凌晨1点执行一次
    public void first() throws InterruptedException {
        sysServiceOrderService.confirmService();
        sysGoodsOrderService.confirmService();
    }

}
